package com.heima.lstener;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class KafkaDemoConsumer {

    @KafkaListener(topics = "demo-topic")
    public void onMessage(ConsumerRecord<String, String> consumerRecord){
        if(consumerRecord == null){
            return;
        }
        log.info("收到kafka的消息：key={},value={}", consumerRecord.key(), consumerRecord.value());
    }

}
